linhall2 2.2.1
Loading...
Searching...
No Matches
linhall2


LIN Hall 2 Click

LIN Hall 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Ilic
  • Date : Oct 2023.
  • Type : ADC type

Software Support

Example Description

This is an example which demonstrates the use of LIN Hall 2 Click board by measuring magnetic field density and showing it in mT as well as detecting the orientation of the magnet.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.LINHall2

Example Key Functions

Application Init

The initialization of ADC module and log UART.

void application_init ( void )
{
log_cfg_t log_cfg;
linhall2_cfg_t linhall2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
linhall2_cfg_setup( &linhall2_cfg );
if ( ADC_ERROR == linhall2_init( &linhall2, &linhall2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define LINHALL2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition linhall2.h:99
#define LINHALL2_ENABLE_DEVICE
LIN Hall 2 EN pin setting.
Definition linhall2.h:80
void application_init(void)
Definition main.c:33
#define MIKROBUS_POSITION_LINHALL2
Definition main.c:27

Application Task

The demo application reads the Magnetic field density and showing it in mT as well as the orientation of the magnet.

void application_task ( void )
{
float mag_flux = 0;
if ( LINHALL2_OK == linhal2_get_flux_density ( &linhall2, &mag_flux ) )
{
log_printf( &logger, " Magnetic flux density: %.3f[mT]\r\n", mag_flux );
if ( 0 < mag_flux )
{
log_printf( &logger, " Magnetic field oriented South \r\n\n" );
}
else
{
log_printf( &logger, " Magnetic field oriented North \r\n\n" );
}
Delay_ms ( 1000 );
}
}
@ LINHALL2_OK
Definition linhall2.h:138
void application_task(void)
Definition main.c:65

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.